package com.abl.core.common.util.password;

import com.abl.core.common.util.MathKit;

public class PWD {
    //判断密码是否输入正确
    public static boolean matchPlainPwd(String inputPlainPassword, String dbPassword) {
        return new BCryptPasswordEncoder().matches(MathKit.getMD5(inputPlainPassword), dbPassword);
    }

    //判断密码是否输入正确
    public static boolean matchMd5Pwd(String inputMd5Password, String dbPassword) {
        return new BCryptPasswordEncoder().matches(inputMd5Password, dbPassword);
    }

    //判断密码是否输入正确
    public static String createPlainPwd(String plainPassword) {
        return new BCryptPasswordEncoder().encode(MathKit.getMD5(plainPassword));
    }

    //判断密码是否输入正确
    public static String createMd5Pwd(String md5Password) {
        return new BCryptPasswordEncoder().encode(md5Password);
    }

    public static void main(String[] args) {
        String pwd = createPlainPwd("123456");
        System.out.println(pwd);
        System.out.println();
        //        String s1 = createPlainPwd("123");
        //        String s2 = createPlainPwd("123");
        //        String s3 = createPlainPwd("123");
        //
        //        System.out.println(s);
        //        System.out.println(s1);
        //        System.out.println(s2);
        //        System.out.println(s3);
        //        //e512babd98feb20c43fa53d11abfe3c3
        //        boolean b2 = matchPwd(MathKit.getMD5("123"), s);
        //        boolean b3 = matchPwd(MathKit.getMD5("123"), s);
        //        boolean b4 = matchPwd(MathKit.getMD5(""), s);
        //        System.out.println(b2);
        //        System.out.println(b3);
        //        System.out.println(b4);
        //
    }

}
